to text so it can be pulled into a spreadsheet or manipulated
with text processing tools.
+ mapconverter
+
+ Mapconverter is a format this is read by Mapopolis.com's mapconverter
+ application. Full details of it's usage are available in the file
+ README.mapconverter.
+
DATA FILTERS
GPSBabel supports data filtering. Data filters are invoked from
--- /dev/null
+Mapconverter is an application used to create userland maps and map data for
+Mapopolis.com's Mapopolis program. The mapconverter format is essentially
+waypoint data prepared in a format that the mapconverter application will
+accept.
+
+The steps for using GPSBabel and Mapconverter go something like this:
+
+Step 1: Create a mapconverter file using gpsbabel.
+ ./gpsbabel -i geo -f geocaching.loc -o mapconverter -F foo.txt
+
+Step 2: Launch mapconverter.exe and choose foo.txt as your input file.
+ Click the begin button to have mapconverter process foo.txt.
+
+If all goes successfully, you should have a file called "foo.pdb" ready
+for syncing with your PDA. Put it wherever Mapopolis thinks it should be
+on your PDA.
+
+NOTES:
+
+o GPSBabel encodes "foo.txt" to have mapconverter use the output filename
+ of "foo.pdb". Similarly, if you tell GPSBabel to write output as
+ "bananagps.txt", mapconverter output will be "bananagps.pdb".
+
+o The PocketPC version of Mapopolis doesn't notice files with the ".pdb"
+ extension. To make this work, change the extension to ".mlp" when
+ copying the mapconverter output to your PocketPC PDA.
+
+o Mapconverter only works with Mapopolis version 3.x. Mapopolis version
+ 4 will refuse to load mapconverter maps. There is no known work-around
+ for this at the time of this writing.
+
+o Mapconverter is no longer available from the Mapopolis website. If you
+ need a copy of mapconverter, ask on your local GPS Software discussion
+ forum and I'm sure someone will have it. As far as I know, It was never
+ actually acknowledged/supported by Mapopolis to begin with.
/* output prologue lines, if any. */
QUEUE_FOR_EACH(&xcsv_file.prologue, elem, tmp) {
- ogp = (ogue_t *) elem;
- fprintf (xcsv_file.xcsvfp, "%s%s", ogp->val, xcsv_file.record_delimiter);
+ char *ol;
+ ogp = (ogue_t *) elem;
+
+ ol = strsub(ogp->val, "__FILE__", xcsv_file.fname);
+
+ if (ol) {
+ fprintf(xcsv_file.xcsvfp, "%s", ol);
+ free(ol);
+ } else {
+ fprintf(xcsv_file.xcsvfp, "%s", ogp->val);
+ }
+ fprintf(xcsv_file.xcsvfp, "%s", xcsv_file.record_delimiter);
}
switch (global_opts.objective ) {
int ofield_ct; /* actual # of ofields */
FILE * xcsvfp; /* ptr to current *open* data file */
+ char * fname; /* ptr to filename of above. */
char * description; /* Description for help text */
char * extension; /* preferred filename extension (for wrappers)*/
int case_ignore_strcmp(const char *s1, const char *s2);
-
+char *strsub(char *s, char *search, char *replace);
void rtrim(char *s);
signed int get_tz_offset(void);
const char *get_cache_icon(const waypoint *waypointp);
"#\n"
"# HEADER STUFF:\n"
"#\n"
-"PROLOGUE Prologue Line 1\n"
+"PROLOGUE Prologue Line 1 __FILE__\n"
"PROLOGUE Prologue Line 2\n"
"#\n"
"# gpsman.c likes mkshort len = 8, whitespace = 0.\n"
;
+static char mapconverter[] =
+"# Format: Mapopolis.com Mapconverter\n"
+"# Author: Gary Paulson\n"
+"# Date: 01/13/2003\n"
+"# Requires unsupported mapconverter.exe from mapopolis.com.\n"
+"#\n"
+"# Modifications by Alex Mottram documented 6/30/2003\n"
+"# Change %-40.40s on description output to %-.40s to stop padding.\n"
+"# Add QUOTE as badchars, remove COMMA.\n"
+"# Removed Mapconverter.exe's README information from style file.\n"
+"# Changed OFIELD to IFIELD in case you ever want to read one of these things.\n"
+"#\n"
+"#\n"
+"DESCRIPTION Mapopolis.com Mapconverter CSV\n"
+"EXTENSION txt\n"
+
+"# FILE LAYOUT DEFINITIIONS:\n"
+
+"FIELD_DELIMITER COMMASPACE\n"
+"RECORD_DELIMITER NEWLINE\n"
+"BADCHARS \",\n"
+
+"# Map Info Record (header):\n"
+"PROLOGUE M, \"Geocaches\", \"GPSBabel\", Geocaches, __FILE__\n"
+"#\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"# L Records:\n"
+"IFIELD CONSTANT, \"L\", \"%s\" # [L]ANDMARK\n"
+"IFIELD CONSTANT, \"Geocaches\", \"%s\" # Category for Landmark Searches\n"
+"IFIELD DESCRIPTION, \"\", \"%-.40s\" # Name\n"
+"IFIELD CONSTANT, \"1\", \"%s\" # View at Zoom Level 1 (1-4)\n"
+"IFIELD LON_DECIMAL, \"\", \"%08.5f\" # Longitude\n"
+"IFIELD LAT_DECIMAL, \"\", \"%08.5f\" # Latitude\n"
+;
static char mxf[] =
"# gpsbabel XCSV style file\n"
"#\n"
"IFIELD DESCRIPTION, \"\", \"%-.78s\"\n"
;
#include "defs.h"
-style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "s_and_t", s_and_t } , { "ozi", ozi } , { "nima", nima } , { "mxf", mxf } , { "gpsman", gpsman } , { "gpsdrive", gpsdrive } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "csv", csv } , { "arc", arc } , {0,0}};
+style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "s_and_t", s_and_t } , { "ozi", ozi } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "gpsman", gpsman } , { "gpsdrive", gpsdrive } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "csv", csv } , { "arc", arc } , {0,0}};
#
# HEADER STUFF:
#
-PROLOGUE Prologue Line 1
+PROLOGUE Prologue Line 1 __FILE__
PROLOGUE Prologue Line 2
#
--- /dev/null
+# Format: Mapopolis.com Mapconverter
+# Author: Gary Paulson
+# Date: 01/13/2003
+# Requires unsupported mapconverter.exe from mapopolis.com.
+#
+# Modifications by Alex Mottram documented 6/30/2003
+# Change %-40.40s on description output to %-.40s to stop padding.
+# Add QUOTE as badchars, remove COMMA.
+# Removed Mapconverter.exe's README information from style file.
+# Changed OFIELD to IFIELD in case you ever want to read one of these things.
+#
+#
+DESCRIPTION Mapopolis.com Mapconverter CSV
+EXTENSION txt
+
+# FILE LAYOUT DEFINITIIONS:
+
+FIELD_DELIMITER COMMASPACE
+RECORD_DELIMITER NEWLINE
+BADCHARS ",
+
+# Map Info Record (header):
+PROLOGUE M, "Geocaches", "GPSBabel", Geocaches, __FILE__
+#
+
+#
+# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:
+#
+# L Records:
+IFIELD CONSTANT, "L", "%s" # [L]ANDMARK
+IFIELD CONSTANT, "Geocaches", "%s" # Category for Landmark Searches
+IFIELD DESCRIPTION, "", "%-.40s" # Name
+IFIELD CONSTANT, "1", "%s" # View at Zoom Level 1 (1-4)
+IFIELD LON_DECIMAL, "", "%08.5f" # Longitude
+IFIELD LAT_DECIMAL, "", "%08.5f" # Latitude
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
+ va_end(ap);
exit(1);
}
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
+ va_end(ap);
}
/*
deg = (signed int) deg_val;
return (double) (deg * 100.0) + ((deg_val - deg) * 60.0);
}
+
+/*
+ * replace a single occurrence of "search" in "s" with "replace".
+ * Returns an allocated copy if substitution was made, otherwise returns NULL.
+ * Doesn't try to make an optimally sized dest buffer.
+ */
+char *
+strsub(char *s, char *search, char *replace)
+{
+ char *p;
+ int len = strlen(s);
+ int slen = strlen(search);
+ int rlen = strlen(replace);
+ char *d;
+
+ p = strstr(s, search);
+ if (!slen || !p) {
+ return NULL;
+ }
+
+ d = xmalloc(len + rlen);
+
+ /* Copy first part */
+ len = p - s;
+ memcpy(d, s, len);
+ d[len] = 0;
+
+ /* Copy replacement */
+ strcat(d, replace);
+
+ /* Copy last part */
+ strcat(d, p + slen);
+ return d;
+}
}
xcsv_file.xcsvfp = fopen(fname, "w");
+ xcsv_file.fname = (char *)fname;
if (xcsv_file.xcsvfp == NULL)
fatal(MYNAME ": Cannot open %s for writing\n", fname);